package com.le.tester.javaThink.fifth.chapter14_StreamingProgramming;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.stream.Collectors;

/**
 * 描述：treeSet
 */
public class TreeSetOfWords {
    public static void main(String[] args) throws IOException {
        TreeSet<String> words = Files.lines(Paths.get("E:\\L.info\\L.Application\\L.Tester\\src\\main\\java\\com\\le\\tester\\java8\\chapter14_StreamingProgramming\\TreeSetOfWords.java"))
                .flatMap(s -> Arrays.stream(s.split("\\W+")))
                .filter(s -> !s.matches("\\d+"))//no number
                .map(String::trim)
                .filter(s -> s.length() > 2)
                .limit(100)
                .collect(Collectors.toCollection(TreeSet::new));

        System.out.println(words);

    }
}
